package LocalDate;

import java.time.LocalDate;
/**
 * LocalDate的判断和计算功能:
 *   LocalDate plusYears(long yearsToAdd) //在原有的年份基础上,加上指定的年份
 *   LocalDate minusMonths(long monthsToSubtract)//在原有月份的基础上,减去指定的月份
 *
 *   boolean isLeapYear() //如果当前年份是闰年,返回true,如果是平年返回false
 *                        // 一个年份如果能被 4整除并且不能被100整除   或者  能被400整除
 *   boolean isEqual(ChronoLocalDate other)//两个日期年月日均相同,返回true,否则返回false
 *   ChronoLocalDate other为LocalDate的接口,多态思想,父类接口实现子类对象
 */
public class LocalDateDemo03 {
    public static void main(String[] args) {
        //method01();加年减月方法
        //methos02();判断是不是闰年
        //method03();判断两个时间的年月日是否完全一致
    }

    private static void method03() {
        LocalDate now = LocalDate.now();
        LocalDate now02 = LocalDate.of(2024, 10, 19);
        System.out.println(now.isEqual(now02));//两个日期年月日均相同,返回true,否则返回false
    }

    private static void methos02() {
        LocalDate now = LocalDate.now();
        System.out.println(now);

        System.out.println(now.isLeapYear());//true
        System.out.println(now.withYear(2014).isLeapYear());//false
    }

    private static void method01() {
        LocalDate now = LocalDate.now();
        System.out.println(now);

        LocalDate now02 = now.plusYears(3);
        System.out.println(now02);

        LocalDate now03 = now.minusMonths(3);
        System.out.println(now03);
    }
}
